#include "mmfacade.h"
#include "amutils.h"

ModelManagerFacade::ModelManagerFacade(QObject *parent) : QObject(parent)
{
    m_Model = 0;
    m_WFImporter = new WFImporter(this);
    m_AMImporter = new AMImporter(this);
    m_AMExporter = new AMExporter(this);
}

ModelManagerFacade::~ModelManagerFacade()
{
      AMUtils::freeModel(m_Model);
}

void ModelManagerFacade::importOBJ(QString filename)
{
    AMUtils::freeModel(m_Model);
    m_Model = m_WFImporter->read(filename);
    emit(modelLoaded(m_Model));
}

void ModelManagerFacade::importAM(QString filename)
{
    AMUtils::freeModel(m_Model);
    m_Model = m_AMImporter->read(filename);
    emit(modelLoaded(m_Model));
}

void ModelManagerFacade::exportAM(QString filename)
{
    if(m_Model == 0) return;
    m_AMExporter->write(filename, m_Model);
}

void ModelManagerFacade::exportOBJ(QString filename)
{

}
